package com.example.common.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import com.example.common.R;
import com.example.common.utils.CustomToastUtil;

/**
 * @author skygge
 * @date 2020/6/4.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：
 */
public class SetLoadingDialog extends Dialog {

    private TextView mMsg;
    private Context mContext;

    public SetLoadingDialog(Context context) {
        super(context, R.style.window_background2);
        this.mContext = context;
    }

    public void setMsg(String msg) {
        mMsg.setText(msg);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_set_loading);
        setCanceledOnTouchOutside(false);
        mMsg = findViewById(R.id.tv_loading);
    }

    @Override
    public void onBackPressed() {
        if (isShowing()){
            CustomToastUtil.showToast(mContext, mContext.getString(R.string.loading));
        }else {
            dismiss();
        }
    }
}
